package leetcode.offer0091;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public int minCost(int[][] costs) {
		int a = costs[0][0], b = costs[0][1], c = costs[0][2];
		for (int i = 1; i < costs.length; i++) {
			int a1 = costs[i][0], b1 = costs[i][1], c1 = costs[i][2];
			int a2 = Math.min(b + a1, c + a1);
			int b2 = Math.min(a + b1, c + b1);
			int c2 = Math.min(a + c1, b + c1);
			a = a2;
			b = b2;
			c = c2;
		}
		return Math.min(a, Math.min(b, c));
	}

	@Override
	public void debug4() {
		H.compare(10, this.minCost(H.str2array1("[[17,2,17],[16,16,5],[14,3,19]]")));
		H.compare(2, this.minCost(H.str2array1("[[7,6,2]]")));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
